// 错题本页面JavaScript

document.addEventListener('DOMContentLoaded', function() {
    // 获取错题数据
    fetchWrongQuestions();
});

// 获取错题数据
function fetchWrongQuestions() {
    // 在实际应用中，这里应该从后端获取数据
    // 模拟数据
    const wrongQuestions = [
        {
            id: 1,
            word: 'apple',
            type: '看图选词',
            lastReview: '2025-11-18',
            reviewCount: 3
        },
        {
            id: 2,
            word: 'banana',
            type: '听音选词',
            lastReview: '2025-11-19',
            reviewCount: 1
        },
        {
            id: 3,
            word: 'cat',
            type: '看词选图',
            lastReview: '2025-11-20',
            reviewCount: 2
        }
    ];
    
    displayWrongQuestions(wrongQuestions);
    updateStats(wrongQuestions);
}

// 显示错题
function displayWrongQuestions(questions) {
    const container = document.getElementById('wrong-questions-container');
    container.innerHTML = '';
    
    questions.forEach(question => {
        const questionElement = document.createElement('div');
        questionElement.className = 'wrong-question-item';
        questionElement.innerHTML = `
            <div class="question-word">${question.word}</div>
            <div class="question-type">${question.type}</div>
            <div class="question-info">
                <span>上次复习: ${question.lastReview}</span>
                <span>复习次数: ${question.reviewCount}</span>
            </div>
        `;
        container.appendChild(questionElement);
    });
}

// 更新统计信息
function updateStats(questions) {
    document.getElementById('total-wrong').textContent = questions.length;
    const totalReviews = questions.reduce((sum, q) => sum + q.reviewCount, 0);
    document.getElementById('review-count').textContent = totalReviews;
}

// 开始复习
function startReview() {
    alert('开始复习功能将在后续版本中实现！');
}